

const dateFormat = (dateStr) => {
  const date = new Date(dateStr)
  const year = date.getFullYear()
  const month = padZero(date.getMonth() + 1)
  const day = padZero(date.getDate())
  const hour = padZero(date.getHours())
  const minute = padZero(date.getMinutes())
  const second = padZero(date.getSeconds())
  return `${year}-${month}-${day} ${hour}:${minute}:${second}`
}

const padZero = (n) => {
  return n < 10 ? '0' + n : n
}

module.exports = {
  dateFormat
}